#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
void tDigest()
{
unsigned char sm3_value[EVP_MAX_MD_SIZE];
int sm3_len, i;
EVP_MD_CTX *sm3ctx;                       
sm3ctx = EVP_MD_CTX_new();
char msg1[] = "20201325";            
      
 
EVP_MD_CTX_init(sm3ctx);                   
EVP_DigestInit_ex(sm3ctx, EVP_sm3(), NULL); 
EVP_DigestUpdate(sm3ctx, msg1, strlen(msg1));
//EVP_DigestUpdate(sm3ctx, msg2, strlen(msg2));
EVP_DigestFinal_ex(sm3ctx, sm3_value, &sm3_len);
EVP_MD_CTX_reset(sm3ctx);                      
 
printf("原数据%s摘要值:\n",msg1);
for(i = 0; i < sm3_len; i++)
{
    printf("0x%x ", sm3_value[i]);
}
printf("\n");
}
int main()
{
OpenSSL_add_all_algorithms();
tDigest();
return 0;
}
